package com.lz.football.module.playerCenter.ComboBox
{
	import com.common.utils.Reflection;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;

	/**
	 * 下拉列表item 
	 * @author Administrator
	 * 
	 */	
	public class ComboBoxItem extends Sprite
	{
		private var _data:Object;
		/**
		 * 皮肤 
		 */
		private var symbolSkin:MovieClip;
		/**
		 *名字 
		 */
		private var _name:TextField;
		/**
		 *框 
		 */
		private var _frame:MovieClip;
//		/**
//		 *阵型  
//		 */
//		private var formation:MovieClip;
		public function ComboBoxItem()
		{
			super();
			init();
		}
		private function init():void
		{
			symbolSkin = Reflection.createInstance("com.lz.modul.playerCenter.comboxItem");
			this.addChild(symbolSkin);
//			_name = symbolSkin._name;
//			formation = symbolSkin.formation;
//			formation.gotoAndStop(1);
			_frame = symbolSkin._frame;
			_frame.alpha = 0;
			_name = symbolSkin.battleText;
			
		}

		/**
		 * 
		 * 
		 */
		private function addEvent():void
		{
			this.addEventListener(MouseEvent.MOUSE_OVER,onOverHandler);
			this.addEventListener(MouseEvent.MOUSE_OUT,onOutHandler);
			this.addEventListener(MouseEvent.CLICK,onClickHandler);
		}
		
		protected function onOverHandler(event:MouseEvent):void
		{
			if(_data == null)return;
			_frame.alpha = 1;
		}
		
		protected function onOutHandler(event:MouseEvent):void
		{
			if(_data == null)return;
			_frame.alpha = 0;
		}
		
		protected function onClickHandler(event:MouseEvent):void
		{
			if(_data == null)return;
			
		}
		/**
		 * 
		 * 
		 */
		private function removeEvent():void
		{
			this.removeEventListener(MouseEvent.MOUSE_OVER,onOverHandler);
			this.removeEventListener(MouseEvent.MOUSE_OUT,onOutHandler);
			this.removeEventListener(MouseEvent.CLICK,onClickHandler);
		}
		/**
		 *数据 
		 */
		public function get data():Object
		{
			return _data;
		}

		/**
		 * @private
		 */
		public function set data(value:Object):void
		{
			_data = value;
			_name.text = value.label +"";
//			formation.gotoAndStop(value.value);
			addEvent();
		}

		/**
		 *清理数据 
		 * 
		 */
		public function clear():void
		{
			_frame.visible = false;
			_name.text = "";
			_data = null;
			removeEvent();
		}
		/**
		 *销毁 
		 * 
		 */
		public function destroyView():void
		{
			removeEvent();
			symbolSkin = null;
			_frame = null;
			_data = null;
		}
	}
}